package com.ruoyi.web.controller.deal;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.deal.info.domain.DealInfo;
import com.ruoyi.deal.info.service.IDealInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 交易订单信息Controller
 *
 * @author zhezhi
 * @date 2022-10-02
 */
@RestController
@RequestMapping("/deal_info/deal_info")
public class DealInfoController extends BaseController
{
    @Autowired
    private IDealInfoService dealInfoService;

    /**
     * 查询交易订单信息列表
     */
    @PreAuthorize("@ss.hasPermi('deal_info:deal_info:list')")
    @GetMapping("/list")
    @ApiOperation("查询交易订单信息列表")
    public TableDataInfo list(DealInfo dealInfo)
    {
        startPage();
        List<DealInfo> list = dealInfoService.selectDealInfoList(dealInfo);
        return getDataTable(list);
    }

    /**
     * 导出交易订单信息列表
     */
    @PreAuthorize("@ss.hasPermi('deal_info:deal_info:export')")
    @Log(title = "交易订单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出交易订单信息列表")
    public void export(HttpServletResponse response, DealInfo dealInfo)
    {
        List<DealInfo> list = dealInfoService.selectDealInfoList(dealInfo);
        ExcelUtil<DealInfo> util = new ExcelUtil<DealInfo>(DealInfo.class);
        util.exportExcel(response, list, "交易订单信息数据");
    }

    /**
     * 获取交易订单信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('deal_info:deal_info:query')")
    @GetMapping(value = "/{infoId}")
    @ApiOperation("获取交易订单信息详细信息")
    public AjaxResult getInfo(@PathVariable("infoId") Long infoId)
    {
        return AjaxResult.success(dealInfoService.selectDealInfoByInfoId(infoId));
    }

    /**
     * 新增交易订单信息
     */
    @PreAuthorize("@ss.hasPermi('deal_info:deal_info:add')")
    @Log(title = "交易订单信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增交易订单信息")
    public AjaxResult add(@RequestBody DealInfo dealInfo)
    {
        return toAjax(dealInfoService.insertDealInfo(dealInfo));
    }

    /**
     * 修改交易订单信息
     */
    @PreAuthorize("@ss.hasPermi('deal_info:deal_info:edit')")
    @Log(title = "交易订单信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改交易订单信息")
    public AjaxResult edit(@RequestBody DealInfo dealInfo)
    {
        return toAjax(dealInfoService.updateDealInfo(dealInfo));
    }

    /**
     * 删除交易订单信息
     */
    @PreAuthorize("@ss.hasPermi('deal_info:deal_info:remove')")
    @Log(title = "交易订单信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{infoIds}")
    @ApiOperation("删除交易订单信息")
    public AjaxResult remove(@PathVariable Long[] infoIds)
    {
        return toAjax(dealInfoService.deleteDealInfoByInfoIds(infoIds));
    }
}
